<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class test extends CI_Controller
{
	public function __construct()
	{
		parent::__construct();
	}
	public function convert()
	{
		
	}
	public function tes()
	{
		
		//$this->load->library('files');
		//$str = "./upload/sanpham/1/";
		//if(is_dir($str)) echo "có"; else echo "không";
		//echo $this->files->createfolder($str);
	}
	public function thuc()
	{
		$this->load->library('account');
		try
		{
			//$arr = array('username'=>'brian','email'=>'developers.vietnam@yahoo.com','sex'=>1,'birthday'=>'1984-07-09','fullname'=>'Bùi Mạnh Cường','phone'=>'0839402665','address'=>'353/4 Tôn Đản P.15 Q.4','city'=>'Hồ Chí Minh','country'=>'Việt Nam');
			//$this->account->logout();
			//echo $this->account->update($arr);
			//$arr = array('username'=>'brian','password'=>'ktnos1vy');
			//echo $this->account->active($arr);
			//echo $this->account->login($arr,TRUE);
			//print_r($this->session->all_userdata());
			//echo $this->account->checkLogin();
			//$this->output->enable_profile(TRUE);
			//echo $this->account->checkStatus($arr);
		}
		catch(Exception $e)
		{
			echo $e->getMessage();
		}
		$arr = array('username'=>'brian','password'=>'ktnos1vy','email'=>'developers.vietnam@yahoo.com','sex'=>1,'birthday'=>'1984-07-09','fullname'=>'Bùi Mạnh Cường','phone'=>'0839402665','address'=>'353/4 Tôn Đản P.15 Q.4','city'=>'Hồ Chí Minh','country'=>'Việt Nam');
		//$chk = $this->account->create($arr); //Tao account don gian
		//$chk = $this->account->create($arr,'full'); //Tao account day du
		//$chk = $this->account->create($arr,'admin'); //Tao account quan tri
	}
	public function ses()
	{
		$newdata = array(
			'username'  => 'johndoe',
			'email'     => 'johndoe@some-site.com',
			'logged_in' => TRUE
		);
		
		$this->session->set_userdata($newdata);
		$arrUser = $this->session->all_userdata();
		//print_r($arrUser);
		print_r($this->session->userdata('email',TRUE));
	}
	public function index()
	{
		$cookie = array(
			'name'   => 'userid',
			'value'  => 'brian',
			'expire' => '2592000' //1ngay: '86400'
		);
		$this->input->set_cookie($cookie);
		
		echo redirect(base_url("test/view"));
	}
	public function view()
	{
		//delete_cookie("userid");
		if(isset($_COOKIE['userid']))
		{
			$some_value = $this->input->cookie('userid',TRUE);
			print_r($some_value);
		}
		else echo "da xoa cookie";
	}
	public function download()
	{
		$filename ="excelreport.xls";
		$contents = "testdata1 \t testdata2 \t testdata3 \t \n testdata1 \t testdata2 \t testdata3 \t";
		header('Content-type: application/ms-excel');
		header('Content-Disposition: attachment; filename='.$filename);
		echo $contents;
	}
	public function loi()
	{
		try
		{
			echo "bat dau<br />";
			//throw new Exception("Loi: 1<br />");
			try
			{
				 echo "tiep tuc<br />";
				 throw new Exception("Loi: 2<br />");
			}
			catch(Exception $e)
			{
				echo $e->getMessage();
			}
		}
		catch(Exception $e)
		{
			echo $e->getMessage();
		}
	}
}